﻿namespace Community.CsharpSqlite.Entity
{
    /*
    ** An instance of the following structure is allocated for each active
    ** savepoint and statement transaction in the system. All such structures
    ** are stored in the Pager.aSavepoint[] array, which is allocated and
    ** resized using sqlite3Realloc().
    **
    ** When a savepoint is created, the PagerSavepoint.iHdrOffset field is
    ** set to 0. If a journal-header is written into the main journal while
    ** the savepoint is active, then iHdrOffset is set to the byte offset
    ** immediately following the last journal record written into the main
    ** journal before the journal-header. This is required during savepoint
    ** rollback (see pagerPlaybackSavepoint()).
    */
    //typedef struct PagerSavepoint PagerSavepoint;
    public class PagerSavepoint
    {
        public long iHdrOffset; /* See above */
        public long iOffset; /* Starting offset in main journal */
        public uint iSubRec; /* Index of first record in sub-journal */
        public uint nOrig; /* Original number of pages in file */
        public Bitvec pInSavepoint; /* Set of pages in this savepoint */

        public static implicit operator bool(PagerSavepoint b)
        {
            return (b != null);
        }
    };
}